@extends('Api.common.title')
@section('content')
    <link rel="stylesheet" href="/static/icheck/minimal/red.css">
    <style>
        .layui-table tbody tr:hover {
            background-color: #e2e2e2;
        }
        .table_box {
            width: 100%;
            height: 680px;
            margin-top: 20px;
            overflow: hidden;
        }

        .rolling {
            width: 100%;
            height: 100%;
            overflow-y: scroll;
            overflow-x: hidden;
            padding-right: 20px;
        }
    </style>
    <div style="padding: 15px;">
        <fieldset class="layui-elem-field">
            <legend>权限管理 - 规则列表</legend>
            <div class="layui-field-box">
                <div class="layui-btn-group">
                    <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog"
                            dw-url="{{ URL::action('Api\RuleController@create')}}?parent_id=0"
                            dw-title="新增菜单"
                            dw-width="800px" dw-height="600px">
                        <i class="layui-icon">&#xe654;</i>新增菜单
                    </button>
                    <button class="layui-btn layui-btn-xs layui-btn-danger dw-batch-delete" dw-url="{{ URL::action('Api\RuleController@delete')}}">
                        <i class="layui-icon">&#xe640;</i>删除
                    </button>
                    <button class="layui-btn layui-btn-xs dw-refresh">
                        <i class="layui-icon">&#x1002;</i>刷新
                    </button>
                </div>
                <div class="table_box">
                    <div class="rolling">
                        <table class="layui-table  layui-form">
                            <colgroup>
                                <col width="120px">
                                <col>
                                <col>
                                <col>
                                <col width="20%">
                                <col>
                                <col>
                                <col width="220">
                            </colgroup>
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>规则名称[唯一标识]</th>
                                <th>规则名称[唯一标识]</th>
                                <th>规则名称[唯一标识]</th>
                                <th>条件</th>
                                <th>状态</th>
                                <th>排序</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($list as $item)
                                <tr>
                                    <td><input type="checkbox" name="id" lay-skin="primary"  value="{{$item["id"]}}" title="{{$item['id']}}"></td>
                                    <td>{{$item['title']}}[{{$item['name']}}]</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td>{{\App\Http\Controllers\PublicController::status_badge($item['status'])}}</td>
                                    <td>{{$item['sort']}}</td>
                                    <td>
                                        <div class="layui-btn-group">
                                            <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog"
                                                    dw-width="800px" dw-height="600px"
                                                    dw-url="edit?id={{$item['id']}}"
                                                    dw-title="编辑用户">
                                                <i class="layui-icon">&#xe642;</i>编辑
                                            </button>

                                            <button class="layui-btn layui-btn-xs dw-dailog"
                                                    dw-width="800px" dw-height="600px"
                                                    dw-url="create?parent_id={{$item['id']}}"
                                                    dw-title="添加下级">
                                                <i class="layui-icon">&#xe652;</i>添加下级
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                @if(key_exists('child',$item))
                                    @foreach($item['child'] as $value)
                                        <tr>
                                            <td><input type="checkbox" name="id" lay-skin="primary"  value="{{$value["id"]}}" title="{{$value['id']}}"></td>
                                            <td></td>
                                            <td>{{$value['title']}}[{{$value['name']}}]</td>
                                            <td></td>
                                            <td></td>
                                            <td>{{\App\Http\Controllers\PublicController::status_badge($item['status'])}}</td>
                                            <td>{{$value['sort']}}</td>
                                            <td>
                                                <div class="layui-btn-group">
                                                    <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog"
                                                            dw-width="800px" dw-height="600px"
                                                            dw-url="edit?id={{$value['id']}}"
                                                            dw-title="编辑用户">
                                                        <i class="layui-icon">&#xe642;</i>编辑
                                                    </button>

                                                    <button class="layui-btn layui-btn-xs dw-dailog"
                                                            dw-width="800px" dw-height="600px"
                                                            dw-url="create?parent_id={{$value['id']}}"
                                                            dw-title="添加下级">
                                                        <i class="layui-icon">&#xe652;</i>添加下级
                                                    </button>
                                                </div>
                                            </td>
                                        </tr>
                                        @if(key_exists('child',$value))
                                            @foreach($value['child'] as $vo)
                                                <tr>
                                                    <td><input type="checkbox" name="id" lay-skin="primary"  value="{{$vo["id"]}}" title="{{$vo['id']}}"></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td>{{$vo['title']}}[{{$vo['name']}}]</td>
                                                    <td></td>
                                                    <td>{{\App\Http\Controllers\PublicController::status_badge($vo['status'])}}</td>
                                                    <td>{{$vo['sort']}}</td>
                                                    <td>
                                                        <div class="layui-btn-group">
                                                            <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog"
                                                                    dw-width="800px" dw-height="600px"
                                                                    dw-url="edit?id={{$vo['id']}}"
                                                                    dw-title="编辑用户">
                                                                <i class="layui-icon">&#xe642;</i>编辑
                                                            </button>

                                                        </div>
                                                    </td>
                                                </tr>
                                            @endforeach
                                        @endif
                                    @endforeach
                                @endif
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </fieldset>
    </div>
@endsection